home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Magazine 28 Bonus
/
CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin
/
data
/
pvtecpl.dir
/
00092_Script_GAME HANDLERS
< prev
next >
Wrap
Text File
|
1996-06-16
|
8KB
|
314 lines
on startMovie
end
on initializePerspectiveGame
global ObjectsFixedList,moveSprite,numberOfPieces
global gridlineButtonOff,gridlineButtonOn,endNarration,gameOverNarration,bad
set numberOfPieces = 19
set moveSprite = 25
set gridlineButtonOn = 32
set gridlineButtonOff = 31
set bad = 10
-- name of the .AIFF that is called when all objects are at their correct positions
set endNarration = "success"
puppetSprite moveSprite,TRUE
removeFromStage(moveSprite)
set ObjectsFixedList = []
global PerspectiveInfo,gridlines,moveSprite,firstPiece,lastPiece
global placedObjects
setpuppets 4,22,TRUE
set PerspectiveInfo = field "Perspective Locations"
set gridlines = 24
set firstPiece = 4
set lastPiece = 22
set placedObjects = [easel2:0,booksshelf:0,bowlbottom:0,carpet:0,box:0,easel1:0,globe:0,clock:0,table:0,cup:0,¼
booktable:0,MiddleBowl:0,TopBowl:0,statue:0,candle:0,skull:0,boxcupboard:0,material:0,¼
cupboardDoor:0]
put 0 into field "totalplaced"
when mouseDown then dragObject(the clickOn)
end
on dragObject aSprite
global objectsFixedList,moveSprite,firstPiece,lastPiece
if (aSprite > firstPiece - 1) AND (aSprite <= lastPiece) then
switchBackPlaced (aSprite)
switchMoveSprites(aSprite)
removeFromStage(aSprite)
track aSprite
if allPlaced() then
waitticks 60
playEnd
end if
end if
end
-- if the sprite is already placed in the correct position, castmnembers have to be changed and
-- the counter "total sprites that are in position" should be adjusted
on switchBackPlaced whichSprite
set nameofCast = the name of cast the castNum of sprite whichSprite
if nameofCast contains "PLACED" then
set newName = word 1 of nameofCast
set the castNum of sprite whichSprite = the number of cast newName
setSizeFigures(whichSprite,NewName)
end if
end
-- switch the (empty) castmember of the sprite that is used to move the clicked sprite¼
-- (moveSprite) to the castmember of the object
on switchMoveSprites whichSprite
global moveSprite
set the castNum of sprite moveSprite = the castNum of sprite whichSprite
set the locH of sprite moveSprite = the mouseH
set the locV of sprite moveSprite = the mouseV
updateStage
end
-- handler MatchHandler gets executed when the object is placed in
-- it's right position
on matchHandler ClickedSprite
global sectionName, sectionRect,marker,objectsFixedList
if marker = 1 then -- change cast to it's "placed" version
set the castNum of sprite ClickedSprite = the number of cast ¼
(sectionName && "Placed")
end if
snapToPoint(ClickedSprite)
updateStage
puppetSound "correct"
updateStage
-- waitTicks 60
-- puppetSound 0
-- sound playFile 1, the pathname & "PVtecPLA:Correct.aif"
end
-- handler snapToPoint sets the coordinates of the clicked sprite (NOT the movesprite!)
-- so that it is visible on the stage
on snapToPoint whichSprite
global sectionRect
spriteBox whichSprite, rectLeft(sectionRect), rectTop(sectionRect), ¼
rectRight(sectionRect), rectBottom(sectionRect)
end
on addObjectToList anObject
global placedObjects
-- set the value of <object> in the list to 1
setaProp placedObjects,anObject,1
end
-- handler deleteObjectFromList deletes an object from a string
on deleteObjectFromList anObject
global placedObjects
-- set the value of <object> in the list to 0
setaProp placedObjects,anObject,0
end
-- handler checkTotalPlaced checks how many objects are positioned correct.It calls handler
-- playEndNarration when all is positioned.
on allPlaced
global placedObjects,numberOfPieces,objectsPlaced
set objectsPlaced = 0
repeat with i = 1 to count(placedObjects)
if getAt(placedObjects,i) = 1 then set objectsPlaced = objectsPlaced + 1
end repeat
put objectsPlaced into field "totalPlaced"
if objectsPlaced = numberOfPieces then return TRUE
end
on setSizeFigures whichSprite,NewName
put the text of cast "sizeMoveFigures" into sizeInfo
repeat with i = 1 to the number of lines in sizeInfo
set figureMove = item 1 of line i of sizeInfo
if figureMove = NewName then
put value(item 2 of line i of sizeInfo)
set the width of sprite whichSprite = value(item 2 of line i of sizeInfo)
set the height of sprite whichSprite =value(item 3 of line i of sizeInfo)
end if
end repeat
end
on track ClickedSprite
global gameOver,moveSprite
-- drag the piece while the mouse is down
repeat while the stillDown
SpriteFollowMouse(moveSprite)
if timeElapsed() then
exit repeat
playGameOver
end if
end repeat
-- the mouse is now Up, ie. the user placed the piece somewhere
-- check if the piece was placed in the right place
removeFromStage(moveSprite)
set objectPlaced = the name of cast (the castNum of sprite ClickedSprite)
if checkhandler() then
matchHandler(ClickedSprite)
addObjectToList objectPlaced -- mark object as placed
else
set the locH of sprite ClickedSprite = the mouseH
set the locV of sprite ClickedSprite = the mouseV
updateStage
deleteObjectFromList objectPlaced -- mark object as NOT placed
end if
end
-- Handler checkHandler returns TRUE if the user placed the
-- outline in the proper place and FALSE otherwise.
on checkHandler
global PerspectiveInfo, sectionName, sectionRect,marker
set sectionRect = 0
repeat with i = 1 to the number of lines in PerspectiveInfo
set lineInfo = line i of PerspectiveInfo
set sectionName = item 1 of lineInfo
if the name of cast the castNum of sprite the clickOn = sectionName then
set leftP = value(item 2 of lineInfo)
set topP = value(item 3 of lineInfo)
set rightP =value( item 4 of lineInfo)
set bottomP =value(item 5 of lineInfo)
set sectionRect = rect(leftP,topP,rightP,bottomP)
set marker = value(item 6 of lineInfo)
exit repeat
end if
end repeat
if (inside(point(the mouseH,the mouseV), sectionRect)) then return TRUE
end
on spriteFollowMouse whichSprite
-- move the piece with the mouse
set the locH of sprite whichSprite = the mouseH
set the locV of sprite whichSprite = the mouseV
updateStage
end
-- set up the playButton in the lower right corner
on setUpPlayButton
puppetSprite 33,TRUE
set the castNum of sprite 33 = the number of cast "PlayButton extended"
updateStage
end
on setUpGridLinesButton
global gridlines
set gridlines = 24
end
-- handler playButton switches the castmember of the clicked sprite. In this
-- case the playbutton switches between a pressed and non-pressed state.
on playButton aSprite
if the name of cast (the castNum of sprite aSprite) = "PlayButton Extended" then
set the castNum of sprite aSprite = the number of cast "PlayButton Pushed"
else
set the castNum of sprite aSprite = the number of cast "PlayButton Extended"
end if
-- updateStage
-- puppetSound "Start Game"
-- updateStage
-- waitTicks 180
-- puppetSound 0
set the castNum of sprite aSprite to the number of cast "empty button"
updateStage
end
on deleteLabel aSprite
set the castNum of sprite aSprite to 0
updateStage
end
on playEnd
global endNarration
puppetSound endNarration
waitSound 1
go "PVtecPlSt1"
end
on playGameOver
global gameOverNarration,objectsPlaced,bad
if objectsPlaced < bad then
set gameOverNarration = "bad"
else
set gameOverNarration = "good"
end if
puppetSound gameOverNarration
waitSound 1
go "PVtecPlSt1"
end
on setpuppets startSprite,endSprite,state
repeat with i = startSprite to endSprite
puppetSprite i,state
end repeat
end